<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        /* 
            需求：将数组的内容倒叙
         */

         const arr = ['a','b','c'];
         let arrResult = arr.reverse()
         console.log(arrResult)

         //排序怎么实现？ 冒泡排序  选择排序
         const arrSort = [1,512,35,123,6,5475,456,23,412,32]
         console.log(arrSort)
         let arrSortResult = arrSort.sort() //默认规则没有意义，按照字符串排序的
        
         console.log(arrSortResult)

         //需求：按照数字大小排序
         arrSort.sort(function (a,b){
             return a-b;    //a在b的后面  升序
         })

          arrSort.sort(function (a,b){
             return b-a;    //  降序
         })
         console.log(arrSort)


         /*
             总结：
                    从小到大：a-b
                    从大到小：b-a
          */
    </script>
</head>
<body>
    
</body>
</html>